Combinatorics

Counting

Goal: Find out ow many members are present in a finite set.

Some Example Counting Problems:

Solving counting problems usually involves converting problems to set cardinality problems.

Multiplication Principle

Multiplication Principle: If there are n possible outcomes for a first event and m possible outcomes for a second event, then there are nm possible outcomes for the sequence of two events.

Mathematical Representation: | A \times B | = | A | * | B |

Examples: Multiplication Principle

Example:

Solution:

Example:

Solution:

Sub-Problem: What if none of the digits can repeat?

Example:

Solution:

Problem: How many three-digit integers (numbers between 100 and 999 inclusive) are even?

Solution: \begin{aligned} \text{(1 to 9)} \times \text{(0 to 9)} \times \text{(even digits)} &= \\ |\{ 1,...,9 \}| \times |\{ 0,...,9 \}| \times |\{ 0,2,4,6,8 \}| &= \\ 9 \times 10 \times 5 &= 450 \text{ integers} \end{aligned}

Addition Principle

Addition Principle: If A and B are disjoint events with n and m outcomes, respectively, then the total number of possible outcomes for event “A or B” is n+m

Mathematical Representation: | A \cup B | = | A | + | B |

Examples: Addition Principle

Example:

Solution:

Example:

Solution:

Example: Using Addition and Multiplication Principle

Problem: How many four-digit numbers begin with a 4 or 5?

Solution: (1*10*10*10) + (1*10*10*10) = 2,000 \text{ 4-digit numbers}

Alternative Solution: (Using only multiplication principle) 2*10*10*10 = 2,000 \text{ 4-digit numbers}

Decision Trees

Decision Trees: Trees that provide the number of outcomes of an event based on a series of possible choices.

Principle of Inclusion and Exclusion

Theory: The union of multiple sets can be found by adding (including) all the elements together and then subtracting (excluding) all the intersections that got double-counted.

Principle of Inclusion and Exclusion on 2 Sets

If A and B are subsets of universal set S, then (A-B),(B-A), and (A \cap B) are disjoint sets. So:

Principle of Inclusion and Exclusion on 2 Sets: | A \cup B | = | A | + | B | - | A \cap B |

Example: How many integers from 1 to 1000 are either multiples of 3 or multiples of 5?

A = \{ \text{Multiples of 3 from 1 to 1000} \} \\ B = \{ \text{Multiples of 5 from 1 to 1000} \} \\~\\ \text{Goal: Find $|A \cup B|$} \\~\\ \begin{aligned} | A \cup B | &= | A | + | B | - | A \cup B | \\ &= \Bigl\lfloor \frac{1000}{3} \Bigr\rfloor + \Bigl\lfloor \frac{1000}{5} \Bigr\rfloor - \Bigl\lfloor \frac{1000}{15} \Bigr\rfloor \\ &= 457 \end{aligned}

Principle of Inclusion and Exclusion on 3 Sets

Principle of Inclusion and Exclusion on 3 Sets: | A \cup B \cup C | = | A | + | B | + | C | - | A \cap B | - | A \cap C | - | B \cap C | + | A \cap B \cap C |

Example: In a class of students undergoing a computer course the following were observed.

  1. How many students know none of the languages?
  1. How many students know all three languages?

| A \cup B \cup C | = 47 \\~\\ \text{Recall: } | A \cup B \cup C | = | A | + | B | + | C | - | A \cap B | - | A \cap C | - | B \cap C | + | A \cap B \cap C | \\~\\ 47 = 30 + 18 + 26 - 9 - 16 - 8 + |A \cap B \cap C| \\ \downarrow \\ |A \cap B \cap C| = 6

Pigeonhole Principle

  1. If more than k items are placed into k bins, then at least one bin has more than one item.
  2. How many people must be in a room to guarantee that two people have the last name begin with the same initial?
  3. How many times must a single die be rolled in order to guarantee getting the same value twice?

Permutations

Permutation: Ordered arrangement of objects.

The number of permutations of r distinct objects chosen from n distinct objects is denoted by P(n,r)

Example: Suppose we have total pool of 10 students (n) and want to know how many ways we can order 5 students (r) without repetition.

Mathematically, for r \le n, an r-permutation from n objects is defined by:

P(n,r) = \frac{ n! }{ (n-r)! }

Tangent: Deriving permutation formula \begin{aligned} P(n,r) &= n \times (n-1) \times (n-2) \times ... \times (n-r+1) \\ &= \frac{ n \times (n-1) \times (n-2) \times ... \times (n-r+1) \times (n-r)! }{ (n-r)! } \end{aligned}

Special Cases

Empty Set: P(n,0)=\frac{n!}{n!}=1

Picking Only One Object: P(n,1)=\frac{n!}{(n-1)!}=n

Arranging n objects: P(n,n)=\frac{n!}{0!}=n!

Examples

Problem: Ten athletes compete in an Olympic event. Gold, silver and bronze medals are awarded to the first three in the event, respectively. How many ways can the awards be presented?

\text{3 Objects from a Pool of 10: } P(10,3) = \frac{10!}{7!} = 720

Problem: How many ways can six people be seated on six chairs?

P(6,6) = 6! = 720

Problem: How many ways can six people be seated in a circle?

\text{In a circle: }=(n-1)!=5!

Problem: How many permutations of the letters ABCDEF contain the letters DEF together in any order?

  1. You can arrange DEF in P(3,3)=3! ways
  2. So really, we are arranging A, B, C, and the whole block of DEF
  3. Using multiplication principle: P(3,3) \times P(4,4) = 3! 4!

Problem: The professor’s dilemma: how to arrange four books on OS, seven on programming, and three on data structures on a shelf such that books on the same subject must be together?

\begin{aligned} \text{All Possible Permutations} &= \text{OS} \times \text{Programming} \times \text{Data Structures} \\ &= [ P(4,4) \times P(7,7) \times P(3,3) \times P(3,3) ] \times P(3,3) \\ &= (4!7!3!)3! \\ &= 4354560 \end{aligned}

Examples: Eliminating Duplicates

Problem: How many distinct permutations can be made from the characters in the word WASHINGTON?

Problem: How many distinct permutations can be made from the characters in the word YORK?

Problem: How many distinct permutations can be made from the characters in the word ILLINOIS?

Problem: How many distinct permutations can be made from the characters in the word MISSISSIPPI?

Combinations

If we don’t care about order in permutations, we’re talking about combinations, which can be calculated with:

C(n,r) = \frac{n!}{(n-r)!r!}

Note: Relationship between Combinations and Permutations:

Note: C(n,r) is much smaller than P(n,r) by definition.

Special Cases

Empty Set: C(n,0) = 1

Choosing One Object: C(n,1) = n

Choosing n Objects From n Objects: C(n,n) = 1

Examples

Problem: How many ways can we select a committee of 3 from 10.

C(10,3) = \frac{10!}{7!3!}

Problem: How many ways can a committee of two women and three men be selected from a group of five different women and six different men?

\text{Two Women from 5 Possible: } C(5,2) = \frac{5!}{3!2!} \\ \text{Three Men from 6 Possible: } C(6,3) = \frac{6!}{3!3!} \\~\\ C(5,2) \times C(6,3) = \frac{5!}{3!2!} \times \frac{6!}{3!3!}

Problem: How many poker hands five-card poker hands contain cards all of the same suit?

C(\text{13 \text{cards in every suit},5 \text{cards in a hand}}) \times 4 \text{ suits} \\ 4C(13,5)=5148

Problem: How many five-card poker hands can be dealt from a standard 52-card deck?

C(52,5)=2,598,960

Exercises: Permutations and Combinations

Problem: How many permutations of the characters in the word COMPUTER are there? How many of these end in a vowel?

\text{Possibilities: C,M,P,T,R,O/U/E (2x),O/U/E (1x)} \text{Permutations Ending in a Vowel: } 3 \times 7!

Problem: How many distinct permutations of the characters in ERROR are there?

\frac{5!}{3!}

Problem: A set of four coins is selected from a box contains five dimes and seven quarters. Find the number of sets which has two dimes and two quarters.

C(5,2) \times C(7,2) = \frac{5!}{3!2!} \times \frac{7!}{5!2!} = 10 \times 21 = 210

Problem: How to select a committee of 3, from 4 men and 3 women, where there must be at least 1 man and 1 woman in the committee.

\frac{ C(4,1) \times C(3,1) \times C(3 \text{ (remaining men)} + 2 \text{ (remaining women)},1) }{ 2 \text{ (for double-counting, because different order doesn't make selections unique)} }

Problem: How many ways can you seat 11 men and 8 women in a row?

P(19,19) = 19!

Problem: How many ways can you seat 11 men and 8 women in a row if all the men sit together and the women sit together?

11! \times 8! \times 2!

Problem: How many ways can you seat 11 men and 8 women in a row where no 2 women are to sit together?

11! \text{ (ways to arrange the men)} \times P(12,8) \text{ (places for the eight women to sit)}

Problem: How many ways can you seat 11 men and 8 women in a circle where no 2 women are to sit together?

10! \text{ (ways to arrange the men in the circle)} \times P(11,8)